package com.freak.kotlinfitnessserver.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.freak.kotlinfitnessserver.room.SupportRangeData
import kotlinx.coroutines.flow.Flow

@Dao
interface SupportRangeDataDao {
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    suspend fun insert(supportRangeData: SupportRangeData): Long

    @Update
    suspend fun update(supportRangeData: SupportRangeData): Int

    @Delete
    suspend fun delete(supportRangeData: SupportRangeData): Int
    @Query("SELECT * from supportRange WHERE deviceType =:deviceType")
    fun getFlowSupportRangeDataListWithDeviceType(deviceType: String): Flow<List<SupportRangeData>>

    @Query("SELECT * from supportRange WHERE deviceType =:deviceType")
    suspend fun getSupportRangeDataListWithDeviceType(deviceType: String): List<SupportRangeData>

    @Query("SELECT * from supportRange WHERE supportRangeType =:supportRangeType")
    fun getSupportRangeDataListWithSupportRangeType(supportRangeType: String): Flow<List<SupportRangeData>>

    @Query("SELECT * from supportRange WHERE supportRangeType =:supportRangeType AND deviceType = :deviceType")
    fun getSupportRangeDataWithSupportRangeTypeAndDeviceType(
        deviceType: String,
        supportRangeType: String
    ): Flow<SupportRangeData>
}